package com.zzyl.controller;

import com.github.pagehelper.Page;
import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "护理项目管理")
@RestController
@Slf4j
@RequestMapping("/nursing_project")
public class NursingProjectController extends BaseController {
    @Autowired
    private NursingProjectService nursingProjectService;

    @GetMapping
    @ApiOperation("分页查询护理项目")
    public ResponseResult<PageResponse<NursingProjectVo>> paramQuery(
            @ApiParam(value = "护理项目名称")  String name,
            @ApiParam(value = "状态：0-禁用，1-启用") Integer status,
            @ApiParam(value = "当前页码")
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页显示数量")
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize
    ){
        PageResponse<NursingProjectVo> pageResponseResult = nursingProjectService.selectQuery(name,status,pageNum,pageSize);
        return success(pageResponseResult);
    }

    /**
     * 新增护理项目
     */
    @PostMapping
    @ApiOperation("新增护理项目")
    public ResponseResult addNursingProject(@RequestBody NursingProjectDto dto){
        nursingProjectService.addNursingProject(dto);
        return success();
    }

    /**
     * 根据Id查询护理
     */
    @ApiOperation("根据Id查询护理")
    @GetMapping("/{id}")
    public ResponseResult<NursingProjectVo> getById(@PathVariable Long id){
       NursingProjectVo vo = nursingProjectService.getById(id);
        return success(vo);
    }

    /**
     * 修改护理项目
     */
    @ApiOperation("修改护理项目")
    @PutMapping
    public ResponseResult updateNursingProject(@RequestBody NursingProjectDto dto){
        nursingProjectService.updateNursingProject(dto);
        return success();
    }

    /**
     * 护理项目的启用禁用
     */
    @ApiOperation("护理项目的启用禁用")
    @PutMapping("/{id}/status/{status}")
    public ResponseResult updateStatus(@ApiParam(value = "护理项目名称") @PathVariable Long id,
                                       @ApiParam(value = "状态：0-禁用，1-启用") @PathVariable Integer status
    ){
        nursingProjectService.updateStatus(id,status);
        return success();
    }

    /**
     * 护理项目的删除
     */
    @ApiOperation("护理项目的删除")
    @DeleteMapping("/{id}")
    public ResponseResult deleteById(@ApiParam(value = "护理项目名称") @PathVariable Long id){
        nursingProjectService.deleteById(id);
        return success();
    }
    /**
     * 1.7查询所有护理项目
     */
    @ApiOperation("查询所有护理项目")
    @GetMapping("/all")
    public ResponseResult<NursingProjectVo> selectAllNursingProject(){
       List<NursingProjectVo> vo = nursingProjectService.selectAllNursingProject();
        return success(vo);
    }
}
